#define _CRT_SECURE_NO_WARNINGS 1


//#include<list>
#include<iostream>
using namespace std;

#include"List.h"
namespace F
{
	void test1()
	{
		list<int> lt;
		lt.push_back(10);
		lt.push_back(20);
		lt.push_back(30);
		lt.push_back(40);
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		list<int> copy(lt);
		for (auto e : copy)
		{
			cout << e << " ";
		}
		cout << endl;

		list<int> lt1;
		lt1.push_back(10);
		lt1.push_back(20);
		lt1.push_back(30);
		lt1.push_back(40);

		lt = lt1;
		for (auto e : copy)
		{
			cout << e << " ";
		}
		cout << endl;
	}
	void test2()
	{
		list<int> lt;
		lt.push_back(10);
		lt.push_back(20);
		lt.push_back(30);
		lt.push_back(40);
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.push_front(5);
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		lt.pop_front();
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;
		cout << lt.size();
		cout << endl;

		while (!lt.empty())
		{
			lt.pop_back();
		}
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;
		cout << lt.size();
		cout << endl;


		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);
		cout << lt.front()<<endl;
		cout << lt.back() << endl;
	}
	void test3()
	{
		list<int> lt;
		lt.push_back(10);
		lt.push_back(20);
		lt.push_back(30);
		lt.push_back(40);
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;

		list<int>::reverse_iterator rit = lt.rbegin();

		while (rit != lt.rend())
		{
			cout << *rit << " ";
			rit++;
		}
		cout << endl;
	}
	void test4()
	{
		list<int> lt;
		lt.push_back(10);
		lt.push_back(20);
		lt.push_back(30);
		lt.push_back(40);

		list<int>::reverse_iterator rit = lt.rbegin();

		while (rit != lt.rend())
		{
			cout << *rit << " ";
			rit++;
		}
		cout << endl;
	}
	void test5()
	{
		list<int> lt;
		lt.push_back(10);
		lt.push_back(20);
		lt.push_back(30);
		lt.push_back(40);

		list<int>::reverse_iterator rit = lt.rend();

		while (rit != lt.rbegin())
		{
			--rit;
			cout << *rit << " ";
		}
		cout << endl;
	}
}
struct AA
{
	int _a1;
	int _a2;

	AA(int a1 = 1, int a2 = 1)
		:_a1(a1)
		, _a2(a2)
	{}
};



int main()
{
	////F::test3();
	//F::list<AA> lt;
	//AA aa1(1, 1);
	//AA aa2(2, 2);
	//lt.push_back(aa1);
	//lt.push_back(aa2);
	//F::list<AA>::iterator it = lt.begin();
	//cout << it->_a1;
	F::test5();
	
	return 0;
}
